﻿@using Telerik.Web.Mvc.UI;
@{
    //page title
    ViewBag.Title = T("Admin.System.Templates.Manufacturer").Text;
}
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-system.png")" alt="" />
        @T("Admin.System.Templates.Manufacturer")
    </div>
</div>
<table class="adminContent">
    <tr>
        <td>
            @(Html.Telerik().Grid<ManufacturerTemplateModel>()
                    .Name("templates-grid")
                    .DataKeys(x =>
                    {
                        x.Add(y => y.Id).RouteKey("Id");
                    })
                    .Columns(columns =>
                    {
                        columns.Bound(x => x.Name);
                        columns.Bound(x => x.ViewPath);
                        columns.Bound(x => x.DisplayOrder);
                        columns.Command(commands =>
                        {
                            commands.Edit().Text(T("Admin.Common.Edit").Text);
                            commands.Delete().Text(T("Admin.Common.Delete").Text);
                        }).Width(200);

                    })
                    .ToolBar(x => x.Insert())
                    .Editable(x =>
                    {
                        x.Mode(GridEditMode.InLine);
                    })
                    .DataBinding(dataBinding =>
                    {
                        dataBinding.Ajax().Select("ManufacturerTemplates", "Template")
                            .Update("ManufacturerTemplateUpdate", "Template")
                            .Delete("ManufacturerTemplateDelete", "Template")
                            .Insert("ManufacturerTemplateAdd", "Template");
                    })
                    .ClientEvents(x => x.OnError("grid_onError"))
                    .EnableCustomBinding(true))
            <script type="text/javascript">
                function grid_onError(e) {
                    alert(e.XMLHttpRequest.responseText);
                    e.preventDefault();
                }
            </script>
        </td>
    </tr>
</table>
